import ToastComponent from './toast.vue'

export default {
  install: function (Vue) {
    const ToastConstructor = Vue.extend(ToastComponent)
    const instance = new ToastConstructor();

    instance.$mount(document.createElement('div'))
    document.body.appendChild(instance.$el)
    // console.log(Vue.prototype)
    // console.log(instance)
    // console.log(instance)
    Vue.prototype.$toast = (msg, duration = 1500, location = 50, icon='') => {
      if (instance.visible) return;

      instance.message = msg;
      instance.visible = true;
      instance.tops = location;
      instance.icons = icon
      setTimeout(() => {
        instance.visible = false;
      }, duration);
    }
  }
}